package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/5/30.
 */
@HttpInlet(Conn.INLET_API_INFORMATION_INDEX) //资讯列表
public class GetApiInformationIndex extends BaseAsyGet<GetApiInformationIndex.Info> {

    public String tid;

    public GetApiInformationIndex(AsyCallBack<GetApiInformationIndex.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");

        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();

            JSONArray array = jsonObject.optJSONArray("data");
            for (int i = 0; i < array.length(); i++) {

                JSONObject o = array.optJSONObject(i);
                DataZixun d = new DataZixun();
                d.id = o.optString("id");
                d.picurl = Conn.PIC + o.optString("picurl");
                d.title = o.optString("title");
                d.posttime = o.optString("posttime");

                info.dataList.add(d);
            }


            return info;
        }

        return null;
    }


    public static class Info {
        public List<DataZixun> dataList = new ArrayList<>();
    }

    public static class DataZixun {
        public String id;
        public String title;
        public String picurl;
        public String posttime;
    }
}
